<template>
	<view class="list-wp">
		<!-- 列表信息 -->
		<view class="list" v-if="list && list.length>0">
			<view class="item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
				<view class="top">
					<view class="time">
						{{item.createTime}}
					</view>
					<view class="status" v-if="item.replyContent">
						已回复
					</view>

				</view>
				<view class="content u-line-2">
					{{item.content}}
				</view>

			</view>

		</view>
		<view class="no-data" v-else>
			<img src="https://file.casugn.com/storecompcard/temp/空页面@2x_1683700615237.png" alt="">
			<view class="no-data-text">
				暂时没有收到您的问题
			</view>
		</view>
		<!-- 添加 -->
		<view class="add-cicle" @click="addClick">
			<img src="https://file.casugn.com/storecompcard//dnjQCUkRUXE760b1c113ff6a4615abf6c68cd2a58582_1681283943428.png"
				alt="">
		</view>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				list: [],
				pageNo: 1,
				pageSize: 10,
				total: 0
			};
		},
		onReachBottom() {
			if (this.pageNo * this.pageSize < this.total) {
				this.pageNo++
				this.getList()
			}
		},
		onShow() {
			this.getList('reset')
		},
		onPullDownRefresh() {
			this.getList('reset')
		},
		computed: {
			...mapGetters(['userInfo']),
		},
		methods: {
			async getList(type) {
				uni.showLoading({

				})
				if (type == 'reset') {
					this.pageNo = 1
					this.total = 0
					this.list = []
				}
				let payload = {
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					openId: this.userInfo.openId
				}
				let res = await this.$api.feedbackList(payload)
				if (res.success && res.result.records) {
					if (type == 'reset') {
						this.list = res.result.records
					} else {
						this.list = [...this.list, ...res.result.records]
					}
					this.total = res.result.total
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
				uni.hideLoading()
				uni.stopPullDownRefresh()
			},
			addClick() {
				if (!this.userInfo.id) {
					return this.$showToast('请先创建名片')
				}
				uni.navigateTo({
					url: '/pagesBusiness/feedback/addFeedback'
				})
			},
			toDetail({
				id
			}) {
				uni.navigateTo({
					url: '/pagesBusiness/feedback/feedbackDetail?id=' + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list-wp {
		position: absolute;
		width: 100%;
		min-height: 100%;
		background-color: #f7f8fa;
		padding-bottom: 80rpx;
		box-sizing: border-box;

		.list {
			min-height: 100%;
			padding-top: 1rpx;


			.item {
				background-color: #fff;
				margin: 32rpx 24rpx;
				padding: 0 24rpx 24rpx 24rpx;
				border-radius: 8rpx;
				box-shadow: 1px 2px 5px #86909C;




				.top {
					height: 88rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					border-bottom: 1rpx dotted #eee;

					.time {
						line-height: 88rpx;
						width: 534rpx;
						font-size: 24rpx;
						color: #86909C;
						line-height: 34rpx;
					}

					.status {
						width: 88rpx;
						height: 40rpx;
						line-height: 40rpx;
						background-color: #E9F0FD;
						color: #276AEE;
						font-size: 24rpx;
						text-align: center;
					}
				}

				.content {
					margin-top: 24rpx;
					width: 638rpx;
					height: 80rpx;
					font-size: 28rpx;
					color: #1D2129;
					line-height: 40rpx;
				}
			}
		}

		.no-data {
			height: 296rpx;
			margin: 0 auto;
			margin-top: 240rpx;
			text-align: center;

			img {
				width: 240rpx;
				height: 240rpx;
			}

			.no-data-text {
				font-size: 28rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #86909C;
				line-height: 39rpx;
				margin-top: 16rpx;
			}

		}

	}


	.add-cicle {
		position: fixed;
		width: 112rpx;
		height: 112rpx;
		background: #276AEE;
		box-shadow: 0rpx 16rpx 32rpx 0rpx rgba(22, 63, 169, 0.4);
		text-align: center;
		border-radius: 50%;
		right: 32upx;
		bottom: 280upx;
		z-index: 50;

		img {
			width: 50upx;
			height: 50upx;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translateX(-25upx) translateY(-25upx);
		}
	}
</style>